API Documentation
Public Member Functions | List of all members
nkMaths::Matrix Class Reference

Represents a 4x4 float matrix. More...

Inheritance diagram for nkMaths::Matrix:

Public Member Functions

 Matrix ()
 
 Matrix (float x0, float y0, float z0, float w0, float x1, float y1, float z1, float w1, float x2, float y2, float z2, float w2, float x3, float y3, float z3, float w3)
 
 Matrix (const Matrix &other)
 
 Matrix (const DirectX::XMMATRIX &values)
 
 ~Matrix ()
 
DirectX::XMMATRIX getValues () const
 
Matrix getInverse () const
 
Matrix getTranspose () const
 
Vector getPositionComponent () const
 
Quaternion getOrientationComponent () const
 
Vector getScaleComponent () const
 
void getDecomposed (Vector &position, Quaternion &orientation, Vector &scale)
 
Vector getFirstRow () const
 
Vector getSecondRow () const
 
Vector getThirdRow () const
 
Vector getFourthRow () const
 
void setToRotationFromQuaternion (const Quaternion &origin)
 
void setToViewMatrixDirection (const Vector &position, const Vector &direction, const Vector &upDirection)
 
void setToPerspectiveMatrix (float fov, float aspect, float nearVal, float farVal)
 
void setToOrthographicMatrix (float fov, float camSpaceWidth, float camSpaceHeight, float nearVal, float farVal)
 
void setToTransformation (const Vector &position, const Quaternion &orientation, const Vector &scale)
 
void inverse ()
 
void transpose ()
 
float get (unsigned int row, unsigned int col) const
 
void set (float val, unsigned int row, unsigned int col)
 
float getDeterminantMat3 () const
 
float getDeterminantMat4 () const
 
float getTraceMat3 () const
 
float getTraceMat4 () const
 
void fromString (const std::string_view &str)
 
Matrixoperator= (const Matrix &other)
 
bool operator== (const Matrix &other)
 
bool operator!= (const Matrix &other)
 
Matrix operator+ (const Matrix &other) const
 
void operator+= (const Matrix &other)
 
Matrix operator- (const Matrix &other) const
 
void operator-= (const Matrix &other)
 
Matrix operator* (const Matrix &other) const
 
Vector operator* (const Vector &toApply) const
 
Matrix operator* (float scalar) const
 
void operator*= (const Matrix &other)
 
void operator*= (float scalar)
 
Matrix operator/ (float scalar) const
 
void operator/= (float scalar)
 

Detailed Description

Represents a 4x4 float matrix.

Constructor & Destructor Documentation

◆ Matrix() [1/4]

nkMaths::Matrix::Matrix ( )

Default constructor.

◆ Matrix() [2/4]

nkMaths::Matrix::Matrix ( float  x0,
float  y0,
float  z0,
float  w0,
float  x1,
float  y1,
float  z1,
float  w1,
float  x2,
float  y2,
float  z2,
float  w2,
float  x3,
float  y3,
float  z3,
float  w3 
)

Filling constructor.

Parameters
x0The x for line 0.
y0The y for line 0.
z0The z for line 0.
w0The w for line 0.
x1The x for line 1.
y1The y for line 1.
z1The z for line 1.
w1The w for line 1.
x2The x for line 2.
y2The y for line 2.
z2The z for line 2.
w2The w for line 2.
x3The x for line 3.
y3The y for line 3.
z3The z for line 3.
w3The w for line 3.

◆ Matrix() [3/4]

nkMaths::Matrix::Matrix ( const Matrix other)

Copy constructor.

Parameters
otherThe matrix to copy from.

◆ Matrix() [4/4]

nkMaths::Matrix::Matrix ( const DirectX::XMMATRIX &  values)

Filling constructor.

Parameters
valuesThe XM values.

◆ ~Matrix()

nkMaths::Matrix::~Matrix ( )

Destructor.

Member Function Documentation

◆ getValues()

DirectX::XMMATRIX nkMaths::Matrix::getValues ( ) const
Returns
The XM values.
Remarks
This API will disappear once the Maths component is created.

◆ getInverse()

Matrix nkMaths::Matrix::getInverse ( ) const
Returns
The inversed matrix.

◆ getTranspose()

Matrix nkMaths::Matrix::getTranspose ( ) const
Returns
The transposed matrix.

◆ getPositionComponent()

Vector nkMaths::Matrix::getPositionComponent ( ) const
Returns
The position component, if we consider the matrix as a 4x4 transformation matrix.

◆ getOrientationComponent()

Quaternion nkMaths::Matrix::getOrientationComponent ( ) const
Returns
The orientation component, if we consider the matrix as a 4x4 transformation matrix.

◆ getScaleComponent()

Vector nkMaths::Matrix::getScaleComponent ( ) const
Returns
The scale component, if we consider the matrix as a 4x4 transformation matrix.

◆ getDecomposed()

void nkMaths::Matrix::getDecomposed ( Vector position,
Quaternion orientation,
Vector scale 
)

Decomposes the matrix into a set of translation, orientation, and scale, if we consider the matrix as a 4x4 transformation matrix.

Parameters
positionThe position, translation component to fill.
orientationThe orientation component to fill.
scaleThe scale component to fill.

◆ getFirstRow()

Vector nkMaths::Matrix::getFirstRow ( ) const
Returns
The first row of the matrix, as a vector.

◆ getSecondRow()

Vector nkMaths::Matrix::getSecondRow ( ) const
Returns
The second row of the matrix, as a vector.

◆ getThirdRow()

Vector nkMaths::Matrix::getThirdRow ( ) const
Returns
The third row of the matrix, as a vector.

◆ getFourthRow()

Vector nkMaths::Matrix::getFourthRow ( ) const
Returns
The fourth row of the matrix, as a vector.

◆ setToRotationFromQuaternion()

void nkMaths::Matrix::setToRotationFromQuaternion ( const Quaternion origin)

Sets the rotation component in the matrix from a quaternion.

Parameters
originThe quaternion to use as orientation.

◆ setToViewMatrixDirection()

void nkMaths::Matrix::setToViewMatrixDirection ( const Vector position,
const Vector direction,
const Vector upDirection 
)

Sets the matrix as a view matrix.

Parameters
positionThe eye position.
directionThe eye front direction.
upDirectionThe eye up direction.

◆ setToPerspectiveMatrix()

void nkMaths::Matrix::setToPerspectiveMatrix ( float  fov,
float  aspect,
float  nearVal,
float  farVal 
)

Sets the matrix as a perspective matrix.

Parameters
fovThe field of view, vertical, in radians.
aspectThe aspect ratio.
nearValThe near plane distance.
farValThe far plane distance.

◆ setToOrthographicMatrix()

void nkMaths::Matrix::setToOrthographicMatrix ( float  fov,
float  camSpaceWidth,
float  camSpaceHeight,
float  nearVal,
float  farVal 
)

Sets the matrix as an orthographic matrix.

Parameters
fovThe field of view, vertical, in radians.
camSpaceWidthThe width of the matrix, in eye space distance.
camSpaceHeightThe height of the matrix, in eye space distance.
nearValThe near plane distance.
farValThe far plane distance.

◆ setToTransformation()

void nkMaths::Matrix::setToTransformation ( const Vector position,
const Quaternion orientation,
const Vector scale 
)

Sets the matrix as a full transformation matrix.

Parameters
positionThe position, translation component to bake.
orientationThe orientation component to bake.
scaleThe scale component to bake.

◆ inverse()

void nkMaths::Matrix::inverse ( )

Inverses the matrix.

◆ transpose()

void nkMaths::Matrix::transpose ( )

Transposes the matrix.

◆ get()

float nkMaths::Matrix::get ( unsigned int  row,
unsigned int  col 
) const
Parameters
rowThe row of the member to retrieve.
colThe col of the member to retrieve.
Returns
The component requested.

◆ set()

void nkMaths::Matrix::set ( float  val,
unsigned int  row,
unsigned int  col 
)
Parameters
valThe value to set in the matrix.
rowThe row to override.
colThe col to override.

◆ getDeterminantMat3()

float nkMaths::Matrix::getDeterminantMat3 ( ) const
Returns
The determinant of the matrix, considered as a 3x3 matrix.

◆ getDeterminantMat4()

float nkMaths::Matrix::getDeterminantMat4 ( ) const
Returns
The determinant of the matrix, considered as a 4x4 matrix.

◆ getTraceMat3()

float nkMaths::Matrix::getTraceMat3 ( ) const
Returns
The trace of the matrix, considered as a 3x3 matrix.

◆ getTraceMat4()

float nkMaths::Matrix::getTraceMat4 ( ) const
Returns
The trace of the matrix, considered as a 4x4 matrix.

◆ fromString()

void nkMaths::Matrix::fromString ( const std::string_view &  str)

Interprets a string to set the components of the matrix. Format is x0,y0,z0,w0,...

Parameters
strThe string to parse.

◆ operator=()

Matrix& nkMaths::Matrix::operator= ( const Matrix other)

Assignment operator.

Parameters
otherThe matrix to assign.
Returns
The calling matrix, once assigned.

◆ operator==()

bool nkMaths::Matrix::operator== ( const Matrix other)

Equality operator.

Parameters
otherThe matrix to check against.
Returns
If the matrices are equal (true) or not (false).

◆ operator!=()

bool nkMaths::Matrix::operator!= ( const Matrix other)

Inequality operator.

Parameters
otherThe matrix to check against.
Returns
If the matrices are different (true) or not (false).

◆ operator+()

Matrix nkMaths::Matrix::operator+ ( const Matrix other) const

Addition operator.

Parameters
otherThe matrix to operate with.
Returns
A matrix resulting from the operation.

◆ operator+=()

void nkMaths::Matrix::operator+= ( const Matrix other)

Addition and assignment operator.

Parameters
otherThe matrix to operate with.

◆ operator-()

Matrix nkMaths::Matrix::operator- ( const Matrix other) const

Subtraction operator.

Parameters
otherThe matrix to operate with.
Returns
A matrix resulting from the operation.

◆ operator-=()

void nkMaths::Matrix::operator-= ( const Matrix other)

Subtraction and assignment operator.

Parameters
otherThe matrix to operate with.

◆ operator*() [1/3]

Matrix nkMaths::Matrix::operator* ( const Matrix other) const

Transformation operator.

Parameters
otherThe matrix to operate with.
Returns
A matrix resulting from the operation.

◆ operator*() [2/3]

Vector nkMaths::Matrix::operator* ( const Vector toApply) const

Transformation operator.

Parameters
toApplyThe matrix to operate with.
Returns
A vector resulting from the operation.

◆ operator*() [3/3]

Matrix nkMaths::Matrix::operator* ( float  scalar) const

Multiplication operator.

Parameters
scalarThe scalar to operate with.
Returns
A matrix resulting from the operation.

◆ operator*=() [1/2]

void nkMaths::Matrix::operator*= ( const Matrix other)

Transformation and assignment operator.

Parameters
otherThe matrix to operate with.

◆ operator*=() [2/2]

void nkMaths::Matrix::operator*= ( float  scalar)

Multiplication and assignment operator.

Parameters
scalarThe scalar to operate with.

◆ operator/()

Matrix nkMaths::Matrix::operator/ ( float  scalar) const

Division operator.

Parameters
scalarThe scalar to operate with.
Returns
A matrix resulting from the operation.

◆ operator/=()

void nkMaths::Matrix::operator/= ( float  scalar)

Addition and assignment operator.

Parameters
scalarThe scalar to operate with.

The documentation for this class was generated from the following file: